/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package session07;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.reflect.Method;

/**
 *
 * @author macbookpro
 */
public class RetentionDemo {
    @Retention(RetentionPolicy.CLASS)
    public static @interface Test_Retention {

        String v1();

        int v2() default 7;
    }

    @Test_Retention(v1 = "Xin chao!", v2 = 9)
    public void thu() {
        System.out.println("Test annotations");
    }

    public static void main(String[] args) {
        RetentionDemo rd = new RetentionDemo();
        try {
            Method m = rd.getClass().getMethod("thu");
            Test_Retention anno = m.getAnnotation(Test_Retention.class);
            System.out.println(anno.v1() + ", " + anno.v2());

        } catch (Exception ex) {
        }
    }
}
